
var app = require('express')()
var server = require('http').createServer(app)
var io = require('socket.io')(server)

app.get('/', function (req, res) {
  res.send('<h1>你好12</h1>')
})

server.listen(9000, () => {
  console.log('服务器开启成功', 9000)
})

io.on('connection', function (socket) {
  console.log('有人连接')
  // 接收 socket
  socket.on('login', function (obj) {
    console.log(obj.username)
    let count = 1
    setInterval(() => {
      socket.emit('relogin', count++)
    }, 1000)
  })
})
